import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import HrSassUI from '@/components'
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
/** this.$router this.$store this.$message
 * 为什么组件上有 this.xxx
 *  因为挂载在原型上
 * 1.导入request
 * 2.把request挂载到原型上
 */
import request from '@/utils/request'
// 我们挂载原型上一般有个规范 就是$XXX 建议规范使用
// 按需导入！！！
// import { imgerror, color } from '@/directives'
import * as directives from '@/directives'
// console.log(directives)
// 注册一个全局自定义指令 `v-focus`
// for in 方法
// for (const key in directives) {
//   const value = directives[key]
//   Vue.directive(key, value)
//   // Vue.directive('imgerror', imgerror)
//   // Vue.directive('color', color)
// }
// console.log(Object.keys(directives))
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})
Vue.prototype.$request = request
// import PageTools from '@/components/PageTools'
// Vue.component('pageTools', PageTools)
// process.env.NODE_ENV === 'production'
// function fn(value, flag = '') {
//   value = value.toString()
//   return value.charAt(0).toUpperCase() + value.slice(1) + flag
// }
// function foo(str, flag = true) {
//   return 'heihei-' + str + (flag ? '!' : '?')
// }

// Vue.filter('fn', fn)
// Vue.filter('foo', foo)
import * as filters from '@/filter'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
Vue.use(HrSassUI)
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
